/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dados;

import net.sourceforge.floggy.persistence.FloggyException;
import net.sourceforge.floggy.persistence.Persistable;
import net.sourceforge.floggy.persistence.PersistableManager;
import net.sourceforge.floggy.persistence.SingleObjectSet;

/**
 *
 * @author Glaucio
 */
public class Conta implements Persistable {

  private String nomeConta;
  private int tipoCoonta;

  public Conta() {
  }

  public void save() {
    try {
      PersistableManager pm = PersistableManager.getInstance();
      pm.setProperty(PersistableManager.STORE_INDEX_AFTER_SAVE_OPERATION, Boolean.TRUE);
      pm.save(this);
    } catch (FloggyException ex) {
      ex.printStackTrace();
    }
  }

  public boolean find(String nomeConta) {
    try {
      PersistableManager pm = PersistableManager.getInstance();
      SingleObjectSet r = pm.find(Conta.class, new FilterNomeConta(nomeConta), null);
      return (r.size() > 0);
    } catch (FloggyException ex) {
      ex.printStackTrace();
    }
    return false;
  }

  /**
   * @return the nomeConta
   */
  public String getNomeConta() {
    return nomeConta;
  }

  /**
   * @param nomeConta the nomeConta to set
   */
  public void setNomeConta(String nomeConta) {
    this.nomeConta = nomeConta;
  }

  /**
   * @return the tipoCoonta
   */
  public int getTipoCoonta() {
    return tipoCoonta;
  }

  /**
   * @param tipoCoonta the tipoCoonta to set
   */
  public void setTipoCoonta(int tipoCoonta) {
    this.tipoCoonta = tipoCoonta;
  }
}